<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>变量的解构赋值</title>
</head>

<body>
    <script>
        //声明一个变量
        // let xiyou = ['唐僧', '孙悟空', '猪八戒', '沙僧'];

        //数组的结构域赋值
        // let tang = xiyou[0];
        // let sun = xiyou[1];
        // let [tang, sun, zhu, sha] = xiyou;


        //声明一个对象 
        let huawei = {
            brand: '华为',
            price: 2399,
            color: '银色',
            storage: '256G',
            detail: {
                cpu: '888',
                pixel: '8000w',
                screen: '6.1'
            }
        };
        //原生方式
        // huawei.brand;
        // huawei.price;
        // huawei.color;
        //解构赋值  非常常用
        //第一层结构的解构
        let {brand, price, color} = huawei;
        //复杂层级的解构
        let { detail: { cpu, pixel, screen } } = huawei;
        // console.log(cpu, pixel, screen, detail);
        //可以选择性结构
        let {storage} = huawei;

        console.log(storage);
    </script>
</body>

</html>